package com.wry.util;

import lombok.Data;

import java.io.Serializable;

/**
 * <h1> 统一接口返回 <h1>
 *
 * @author 魏如元
 * @since 2022/10/11
 */
@Data
public class ApiResult<T> implements Serializable {

    private Integer code;

    private String msg;

    private T data;

    public ApiResult() {
    }

    public ApiResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ApiResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ApiResult<String> SUCCESS(String msg){
        return new ApiResult<>(200,msg);
    }

    public static <T>ApiResult<T> SUCCESS(T data){
        return new ApiResult<>(200,"ok", data);
    }
}
